#include "Texture.h"
#include "Graphics.h"
#include "ReportError.h"

Texture::Texture()
{
	m_Texture = 0;
}

Texture::~Texture()
{
	if(m_Texture)
	{
		m_Texture->Release();
		m_Texture = 0;
	}
}

bool Texture::Load(const std::string &filename)
{
	HRESULT HR = D3DX10CreateShaderResourceViewFromFile(TheGraphics::Instance()->GetD3DDevice(), filename.c_str(),NULL, NULL, &m_Texture, NULL);
	if(FAILED(HR))
	{
		std::string error = "Failed Loading Texture:";
		error += filename.c_str();

		ReportError(error.c_str());
		return false;
	}
	return true;
}
